package com.ujiuye.controller;


import com.ujiuye.config.MessageConstant;
import com.ujiuye.config.Result;
import com.ujiuye.pojo.Setmeal;
import com.ujiuye.service.ISetmealService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 中间表  一个套餐有什么检查组 前端控制器
 * </p>
 *
 * @author zs
 * @since 2021-07-05
 */
@RestController
@RequestMapping("/setmeal")
public class SetmealController {

    @Reference
    private ISetmealService setmealService;

    @GetMapping("list")
    public Result list(){
        try {
            List<Setmeal> list = setmealService.list();
            return new Result(true, MessageConstant.QUERY_SETMEAL_SUCCESS,list);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false,MessageConstant.QUERY_SETMEAL_FAIL);
        }
    }

    @GetMapping("getById/{id}")
    public Result getSetMeal(@PathVariable("id") int id){
        try {
            Setmeal setMeal = setmealService.getSetMeal(id);
            return new Result(true,MessageConstant.QUERY_SETMEALLIST_SUCCESS,setMeal);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false,MessageConstant.QUERY_SETMEALLIST_FAIL);
        }
    }




}

